package com.janus.multitypedemo.vb;

import android.support.annotation.NonNull;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.janus.multitypedemo.R;
import com.janus.multitypedemo.bean.Good;

import me.drakeet.multitype.ItemViewBinder;

/**
 * Created by janus on 2017/7/10.
 * BannerViewBinder
 */

public class GoodViewBinder extends ItemViewBinder<Good, GoodViewBinder.ViewHolder> {

    @NonNull
    @Override
    protected ViewHolder onCreateViewHolder(@NonNull LayoutInflater inflater, @NonNull ViewGroup parent) {
        View view = inflater.inflate(R.layout.layout_good, parent, false);
        return new ViewHolder(view);
    }

    @Override
    protected void onBindViewHolder(@NonNull ViewHolder holder, @NonNull Good item) {
        Glide.with(holder.ivGood.getContext())
                .load(item.url)
                .into(holder.ivGood);
        holder.tvGood.setText(item.title);
        holder.tvGoodTS.setText(item.type_size);
    }

    public class ViewHolder extends RecyclerView.ViewHolder {

        ImageView ivGood;
        TextView tvGood;
        TextView tvGoodTS;

        public ViewHolder(View itemView) {
            super(itemView);
            ivGood = (ImageView) itemView.findViewById(R.id.iv_good);
            tvGood = (TextView) itemView.findViewById(R.id.tv_good);
            tvGoodTS = (TextView) itemView.findViewById(R.id.tv_good_type_size);
        }

    }
}
